//
//  StatusOraigianView.swift
//  sinaweibo
//
//  Created by icefs2 on 15/11/15.
//  Copyright © 2015年 icefs2. All rights reserved.
//

import UIKit
import SDWebImage
class StatusOraigianView: UIView {
    //数据模型
    var status: Status? {
        didSet {
            iconImage.sd_setImageWithURL(status?.user?.headImageURL, placeholderImage: UIImage(named: "avatar_default_big"))
            nameLable.text = status?.user?.name
            menmberIconView.image = status?.user?.mbrankImage
            verifiedIconView.image = status?.user?.verified_type_Image
            timelable.text = "11:11" //status?.created_at
            sourceLable.text = "隔壁老王"//status?.source
            contentLable.text = status?.text
            pictureView.imageURLs = status?.imageURLs
        }
    }
    

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupuI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置ui
    private func setupuI() {
        backgroundColor = UIColor(white: 0.95, alpha: 1)
        addSubview(iconImage)
        addSubview(nameLable)
        addSubview(menmberIconView)
        addSubview(verifiedIconView)
        addSubview(timelable)
        addSubview(sourceLable)
        addSubview(contentLable)
       addSubview(pictureView)
        //设置约束
        iconImage.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top).offset(StatusCellMargin)
            make.left.equalTo(snp_left).offset(StatusCellMargin)
            make.height.equalTo(StatusCellIconWitdth)
            make.width.equalTo(StatusCellIconWitdth)
        }
       nameLable.snp_makeConstraints { (make) -> Void in
        make.top.equalTo(iconImage.snp_top)
        make.left.equalTo(iconImage.snp_right).offset(StatusCellMargin)
        }
        verifiedIconView.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(iconImage.snp_right)
            make.centerY.equalTo(iconImage.snp_bottom)
        }
        menmberIconView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(nameLable.snp_top)
            make.left.equalTo(nameLable.snp_right).offset(StatusCellMargin)
        }
        timelable.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(iconImage.snp_bottom)
            make.left.equalTo(iconImage.snp_right).offset(StatusCellMargin)
        }
       sourceLable.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(timelable.snp_bottom)
            make.left.equalTo(timelable.snp_right).offset(StatusCellMargin)
        }
        contentLable.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(iconImage.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(iconImage)
        }
        pictureView.snp_makeConstraints { (make) -> Void in
        make.top.equalTo(contentLable.snp_bottom).offset(StatusCellMargin)
        make.left.equalTo(contentLable.snp_left)
            make.width.equalTo(100)
            make.height.equalTo(100)
        }
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(pictureView.snp_bottom).offset(StatusCellMargin)
        }
   }
    // 懒加载控件
    private lazy var iconImage: UIImageView = UIImageView(image: UIImage(named: "avatar_default_big"))
    private lazy var nameLable: UILabel = UILabel(title: "iosicefs", size: 14, color: UIColor.darkGrayColor())
    private lazy var verifiedIconView: UIImageView = UIImageView(image: UIImage(named: "avatar_vip"))
    private lazy var menmberIconView: UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level1"))
    private lazy var timelable: UILabel = UILabel(title: "", size: 10, color: UIColor.orangeColor())
    private lazy var sourceLable: UILabel = UILabel(title: "", size: 10, color: UIColor.lightGrayColor())
    private lazy var contentLable: UILabel = UILabel(title: "野内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮内心的攻城狮", size: 14, color: UIColor.blackColor(), margin: StatusCellMargin)

    private lazy var pictureView: StatusPictureView = StatusPictureView()
}
